package org.wxy.test.test1;

import java.util.Arrays;
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        String str;
        int i;
        int n;
        n=sc.nextInt();
        Shape[] shape=new Shape[n] ;
        for(i=0;i<n;i++)
        {
            str=sc.nextLine();
            if(str.equals("rect"))
            {
                shape[i]=new Rectangle(sc.nextInt(), sc.nextInt());
                sc.nextLine();
            }
            else
            {
                shape[i]=new Circle(sc.nextInt());
            }
        }
        System.out.println(Shape.sumAllPerimeter(shape));
        System.out.println(Shape.sumAllArea(shape));
        System.out.println(Arrays.toString(shape));
        for(Shape s:shape)
        {
            System.out.println(s.getClass()+","+s.getClass().getSuperclass());
        }
    }

}

abstract class Shape
{
    static double PI=3.14;
    abstract public double getPerimeter();
    abstract public double getArea();

    public static double sumAllArea(Shape[] ss)
    {
        double ret=0;
        for(Shape s:ss)
        {
            ret+=s.getArea();
        }
        return ret;
    }
    public static double sumAllPerimeter(Shape[] ss)
    {
        double ret=0;
        for(Shape s:ss)
        {
            ret+=s.getPerimeter();
        }
        return ret;
    }
}
class Rectangle extends Shape
{
    private int width;
    private int length;
    public Rectangle(int width,int length)
    {
        this.width=width;
        this.length=length;
    }
    public double getPerimeter()
    {
        return 2*(width+length);
    }
    public double getArea()
    {
        return width*length;
    }
    public String toString()
    {
        return "Rectangle ["+"width="+width+", length="+ length + ']';
    }
}
class Circle extends Shape
{
    int radius;
    public Circle(int r)
    {
    	this.radius=r;
    }
    public double getArea()
    {
        return PI*radius*radius;
    }
    public double getPerimeter()
    {
        return 2*PI*radius;
    }
    public String toString()
    {
        return "Circle [" + "radius=" + radius + ']';
    }
}

